1 /* 2 Copyright: Marcelo S. N. Mancini (Hipreme|MrcSnm), 2018 - 2021 3 License: [https://creativecommons.org/licenses/by/4.0/|CC BY-4.0 License]. 4 Authors: Marcelo S. N. Mancini 5 6 Copyright Marcelo S. N. Mancini 2018 - 2021. 7 Distributed under the CC BY-4.0 License. 8 (See accompanying file LICENSE.txt or copy at 9 https://creativecommons.org/licenses/by/4.0/ 10 */ 11 module hip.bind.external; 12 13 14 version(UWP) 15 { 16 import core.sys.windows.windef; 17 import core.sys.windows.unknwn; 18 import core.sys.windows.winbase; 19 struct HipExternalCoreWindow 20 { 21 IUnknown coreWindow; 22 uint logicalWidth; 23 uint logicalHeight; 24 } 25 extern(Windows) nothrow @system __gshared 26 { 27 HipExternalCoreWindow function() getCoreWindow; 28 void function(const(wchar*) wcstr) OutputUWP; 29 30 HANDLE function( 31 LPCWSTR lpFileName, 32 DWORD dwDesiredAccess, 33 DWORD dwShareMode, 34 LPSECURITY_ATTRIBUTES lpSecurityAttributes, 35 DWORD dwCreationDisposition, 36 DWORD dwFlagsAndAttributes, 37 HANDLE hTemplateFile 38 ) UWPCreateFileFromAppW; 39 40 BOOL function(LPCWSTR lpFileName 41 ) UWPDeleteFileFromAppW; 42 43 BOOL function( 44 LPCWSTR lpFileName, 45 GET_FILEEX_INFO_LEVELS fInfoLevelId, 46 LPVOID lpFileInformation 47 ) UWPGetFileAttributesExFromAppW; 48 } 49 void uwpPrint(string str) 50 { 51 import std.utf:toUTF16z; 52 OutputUWP(toUTF16z(str~"\n")); 53 } 54 } 55 56 57 void importExternal() 58 { 59 import hip.util.system; 60 version(UWP) 61 { 62 string[] errors = dllImportVariables!( 63 ///App.cpp 64 getCoreWindow, 65 OutputUWP, 66 67 ///uwpfs.h 68 UWPCreateFileFromAppW, 69 UWPDeleteFileFromAppW, 70 UWPGetFileAttributesExFromAppW 71 ); 72 73 assert(OutputUWP != null, "Failed loading OutputUWP"); 74 75 foreach(err; errors) 76 uwpPrint("HIPREME_ENGINE: Could not load function "~err); 77 } 78 }